package io.renren.modules.business.controller;

import java.util.Arrays;
import java.util.Map;

import io.renren.modules.business.entity.BusAssessmentRecordEntity;
import io.renren.modules.business.service.BusAssessmentRecordService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;

/**
 * 考勤记录
 *
 * @author liao mengqing
 */
@RestController
@RequestMapping("business/asserecord")
public class BusAssessmentRecordController {
    @Autowired
    private BusAssessmentRecordService busAssessmentRecordService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("business:asserecord:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = busAssessmentRecordService.queryPage(params);
        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{recordId}")
    @RequiresPermissions("business:asserecord:info")
    public R info(@PathVariable("recordId") Long recordId){
		BusAssessmentRecordEntity busAssessmentRecord = busAssessmentRecordService.getById(recordId);

        return R.ok().put("busAssessmentRecord", busAssessmentRecord);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("business:asserecord:save")
    public R save(@RequestBody BusAssessmentRecordEntity busAssessmentRecord){
		busAssessmentRecordService.save(busAssessmentRecord);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("business:asserecord:update")
    public R update(@RequestBody BusAssessmentRecordEntity busAssessmentRecord){
		busAssessmentRecordService.updateById(busAssessmentRecord);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("business:asserecord:delete")
    public R delete(@RequestBody Long[] recordIds){
		busAssessmentRecordService.removeByIds(Arrays.asList(recordIds));

        return R.ok();
    }

}
